package com.tdcoding.chat.listener;

import com.tdcoding.chat.entities.ChatInfo;
import com.tdcoding.chat.helper.Logger;
import com.tdcoding.chat.manager.MQManager;

import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;

/**
 * 发送聊天消息j
 * @author Administrator
 *
 */
public class IChannelChatListener implements GenericFutureListener<Future<? super Void>> {
	private ChatInfo chatInfo;
	public IChannelChatListener(ChatInfo chatInfo) {
		this.chatInfo=chatInfo;
	}

	@Override
	public void operationComplete(Future<? super Void> future) throws Exception {
		Logger.println(this, "operationComplete",future.isCancelled(),future.isSuccess());
		if (future.isCancelled()) {
			MQManager.pushMsg(chatInfo);
		}
		else{
			if (!future.isSuccess()) {
				MQManager.pushMsg(chatInfo);
			} 
		}
	}
}